<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('AdminDiary/index')}">日记管理</a></li>
        <li><a href="{:url('AdminDiary/add')}">添加日记</a></li>
    </ul>
    <form class="well form-inline margin-top-20 bg-white" method="get" action="{:url('AdminDiary/index')}">
        内容:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$keyword|default=''}" placeholder="请输入关键字">
        <button class="btn btn-primary">搜索</button>
    </form>
    <form method="post" class="js-ajax-form margin-top-20">
        <div class="table-actions">
            <!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>ID</th>
                <th>年份</th>
                <th>内容</th>
                <th>状态</th>
                <th>创建时间</th>
                <th width="160">操作</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="diaries"  item="vo">
                <tr>
                    <td title="ID:{$vo.id}">{$vo.id}</td>
                    <td title="ID:{$vo.year}">{$vo.year}</td>
                    <td title="ID:{$vo.msg}">{$vo.msg}</td>
                    <td>
                        <eq name="vo.status" value="1">
                            <span class="label label-success">{$arrStatus[$vo['status']]}</span>
                            <else/>
                            <span class="label label-warning">{$arrStatus[$vo['status']]}</span>
                        </eq>
                    </td>
                    <td title="ID:{$vo.create_time}">{:date('Y-m-d',$vo.create_time)}</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="javascript:;"
                           onclick="openPortalDiaryEditDialog(this)"
                           data-href="{:url('AdminDiary/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
                        <eq name="vo.status" value="1">
                            <a class="btn btn-xs btn-warning js-ajax-dialog-btn"
                               href="{:url('AdminDiary/upStatus',['id'=>$vo['id'],'status'=>0])}">禁用</a>
                            <else/>
                            <a class="btn btn-xs btn-success js-ajax-dialog-btn"
                               href="{:url('AdminDiary/upStatus',['id'=>$vo['id'] ,'status'=>1])}">启用</a>
                        </eq>
                        <a class="btn btn-xs btn-danger js-ajax-delete"
                           href="{:url('AdminDiary/delete',['id'=>$vo['id']])}">删除</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
            <tfoot>
            <tr>
                <th>ID</th>
                <th>年份</th>
                <th>内容</th>
                <th>状态</th>
                <th>创建时间</th>
                <th width="160">操作</th>
            </tr>
            </tfoot>
        </table>
        <div class="table-actions">
            <!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
        </div>
    </form>
    <ul class="pagination">{$page|default=''}</ul>
</div>
<script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
<script>
    function openPortalDiaryEditDialog(obj) {
        var $obj = $(obj);
        var href = $obj.data('href');
        parent.openIframeLayer(href, '编辑日记', {
            area: GV.IS_MOBILE ? ['100%', '100%'] : ['95%', '95%'],
            offset: GV.IS_MOBILE ? ['0px', '0px'] : 'auto',
            // btn: ['确定', '取消'],
            yes: function (index, layero) {
                console.log(layero);
                var iframeWin = parent.window[layero.find('iframe')[0]['name']];
                //iframeWin.confirm();
                parent.layer.close(index); //如果设定了yes回调，需进行手工关闭
            },
            end: function () {
            }
        });
    }
</script>
</body>
</html>
